package com.wc.AlgoOJ_homework.AlgoOJ_HomeWork2.M_子串分值;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/6 8:52
 * @description http://43.138.190.70:8888/p/LQ1101?tid=65e6b15c27489dab814f8d41
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static char[] s;

    public static void main(String[] args) {
        s = sc.next().toCharArray();
        // 做到左边第一个等于当前位置的值，找到右边第一个等于当前位置的值，极限的情况，因为最多只有128个字符，也就是256个遍历100010也就2*10^7
        // 的时间复杂度
        int n = s.length;
        long res = 0;
        for (int i = 0; i < n; i++) {
            int l = i - 1;
            int r = i + 1;
            while (l >= 0 && s[l] != s[i]) {
                l--;
            }
            while (r < n && s[r] != s[i]) {
                r++;
            }
            res += (long) (i - l) * (r - i);
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}